<?php
namespace jy_shifu;
defined('BY_JYA') or exit('error');
/*
*/
class notice extends \plugin{
	public function gettpl_data($orderid,$type=0){//type=0表单订单，type=1
		return false;
	}
	/*
		师傅新任务通知
	*/
	public function notice_orderget($order_id,$url=''){
		//新师傅任务通知给师傅
		$order=model('jy_weishop/order')->get_order($order_id);
		$address=pdo_get('core_address',array('id'=>$order['addressid']),array('pcd','address','mobile'));
		$mobile=pdo_getcolumn('core_members',array('id'=>$order['mid']),'mobile');
		$mobile=$mobile?:$address['mobile'];
		$address['pcd']=json_decode($address['pcd'],true);
		$address=$address['pcd']['province'].' '.$address['pcd']['city'].' '.$address['pcd']['district'].' '.$address['pcd']['street'].''.$address['address'];
		$template_id=cfc('account')->get_tpl_template_id('OPENTM416739152','新师傅任务通知');
		if($_SESSION['wxapp_id']){
			$wxapptemplate_id=cfc('wxapp_api')->get_tpl_template_id('17468',[1,2,3,7],'orderget','新师傅任务通知','jy_shifu');
		}
		$message=array(
			'first'=>array('value'=>'新师傅任务通知',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$order['ordersn'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>date('Y/m/d H:i:s',$order['createtime']),"color" => "#4a5077"),
			'keyword3'=>array('value'=>$order['goods']['0']['title'],"color" => "#4a5077"),
			'keyword4'=>array('value'=>$address,"color" => "#4a5077"),
			'remark'=>array('value'=>'您有新的师傅订单！请及时处理！点击“详情”查看订单信息。',"color" => "#4a5077"),
		);
		$wxappmsg=array(
			array('value'=>$order['ordersn']),
			array('value'=>date('Y/m/d H:i:s',$order['createtime'])),
			array('value'=>$order['goods']['0']['title']),
			array('value'=>$address),
		);
		if(!$url){
			$url=custom_url('jy_shifu/worker_order/detail/id='.$order['id'],true);	
		}
		if(method_exists(cfc('account'),'sendtwoNotice')){
			cfc('account')->sendtwoNotice($order['shifu_id'],$template_id,$message,$url,'orderget','jy_shifu',$order_id);
		}
		if($_SESSION['wxapp_id']){
			$url='/jy_shifu/worker_order/detail/index?id='.$order['id'];
			$template_id=cfc('wxapp_api')->checktplNotice($order['shifu_id'],$wxapptemplate_id,$wxappmsg,$url,'orderget','jy_shifu',$order_id);
		}
	}
}